package umaine.ece471.cookbook;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

//sets up and populates the main screen of the application
//allows for navigation throughout the application by using intents
public class CookbookActivity extends Activity {
	private static final int REQUEST_CODE = 10;
	private Button create;
	private Button search;
	private Button newsFeed;

	
	
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);									//sets up screen with customized main.xml code
        this.setTitle("Cookbook - Home");
        
        
        create = (Button) findViewById(R.id.create);					//finds button that allows user to create a recipe
        search = (Button) findViewById(R.id.search);					//finds button that allows user to search for recipes
        newsFeed = (Button) findViewById(R.id.newsFeed);				//finds button that allows user to look through their favorite recipes
        
        create.setOnClickListener(new View.OnClickListener() {			//when create button is clicked an intent is used to go to the createNew.java class
        	public void onClick(View v) {
        		Intent i = new Intent(CookbookActivity.this, CreateNew.class);
        		startActivityForResult(i, REQUEST_CODE);
        	}
        });
        
        search.setOnClickListener(new View.OnClickListener() {			//when search button is clicked an intent is used to go to the searchAll.java class
        	public void onClick(View v) {
        		Intent i1 = new Intent(CookbookActivity.this, SearchAll.class);
        		startActivityForResult(i1, REQUEST_CODE);
        	}
        });
        
        newsFeed.setOnClickListener(new View.OnClickListener() {		//when favorite button is clicked an intent is used to go to the favorites.java class
			public void onClick(View v) {
				Intent i2 = new Intent(CookbookActivity.this, NewsFeed.class);
				startActivity(i2);
			}
		});
    }

}